// Copyright (C) 1953-2023 NUDT
// Verilog module name - sync_and_measure_cache
// Version: V4.3.0.20240125
// Created:
//         by - fenglin 
////////////////////////////////////////////////////////////////////////////
// Description:
//         sync and measure state cache
///////////////////////////////////////////////////////////////////////////
module sync_and_measure_cache
(
    i_clk,
    i_rst_n,
    i_rd,                          

    iv_measure_t1,
    iv_measure_t2,
    iv_measure_t3,
    iv_measure_t4,
    i_measure_state_wr,
    iv_timestamps_port_id,
    iv_port_ptp_enabled,

    i_sync_ok,
    iv_offset_abnormal_cnt,
    iv_offset,
    i_sync_state_wr,
    iv_gm_timestamps,
    iv_correctfield_time,
    iv_mac_time,
    iv_tsc_time,
    iv_sync_link_delay,
    iv_corrent_sync_clk,
    iv_clk_set_time,
    iv_cyclestart_sequenceid,
    iv_tick_length,
    iv_csrateoffset_previousnode,
    i_csrateoffset_previousnode_wr,

    ov_p0_t1,
    ov_p0_t2,
    ov_p0_t3,
    ov_p0_t4,
    ov_p1_t1,
    ov_p1_t2,
    ov_p1_t3,
    ov_p1_t4,
    ov_p2_t1,
    ov_p2_t2,
    ov_p2_t3,
    ov_p2_t4,
    ov_p3_t1,
    ov_p3_t2,
    ov_p3_t3,
    ov_p3_t4,
    ov_p4_t1,
    ov_p4_t2,
    ov_p4_t3,
    ov_p4_t4,
    ov_p5_t1,
    ov_p5_t2,
    ov_p5_t3,
    ov_p5_t4,
    ov_p5_t1,
    ov_p5_t2,
    ov_p5_t3,
    ov_p5_t4,
    ov_p6_t1,
    ov_p6_t2,
    ov_p6_t3,
    ov_p6_t4,
    ov_p7_t1,
    ov_p7_t2,
    ov_p7_t3,
    ov_p7_t4,
    ov_p8_t1,
    ov_p8_t2,
    ov_p8_t3,
    ov_p8_t4,
    ov_p9_t1,
    ov_p9_t2,
    ov_p9_t3,
    ov_p9_t4,
    ov_p10_t1,
    ov_p10_t2,
    ov_p10_t3,
    ov_p10_t4,
    ov_p11_t1,
    ov_p11_t2,
    ov_p11_t3,
    ov_p11_t4,
    ov_p12_t1,
    ov_p12_t2,
    ov_p12_t3,
    ov_p12_t4,
    ov_p13_t1,
    ov_p13_t2,
    ov_p13_t3,
    ov_p13_t4,
    ov_p14_t1,
    ov_p14_t2,
    ov_p14_t3,
    ov_p14_t4,
    ov_p15_t1,
    ov_p15_t2,
    ov_p15_t3,
    ov_p15_t4,
    ov_p16_t1,
    ov_p16_t2,
    ov_p16_t3,
    ov_p16_t4,
    ov_p17_t1,
    ov_p17_t2,
    ov_p17_t3,
    ov_p17_t4,
    ov_p18_t1,
    ov_p18_t2,
    ov_p18_t3,
    ov_p18_t4,
    ov_p19_t1,
    ov_p19_t2,
    ov_p19_t3,
    ov_p19_t4,
    ov_p20_t1,
    ov_p20_t2,
    ov_p20_t3,
    ov_p20_t4,
    ov_p21_t1,
    ov_p21_t2,
    ov_p21_t3,
    ov_p21_t4,
    ov_p22_t1,
    ov_p22_t2,
    ov_p22_t3,
    ov_p22_t4,
    ov_p23_t1,
    ov_p23_t2,
    ov_p23_t3,
    ov_p23_t4,
    ov_p24_t1,
    ov_p24_t2,
    ov_p24_t3,
    ov_p24_t4,
    ov_p25_t1,
    ov_p25_t2,
    ov_p25_t3,
    ov_p25_t4,
    ov_p26_t1,
    ov_p26_t2,
    ov_p26_t3,
    ov_p26_t4,
    ov_p27_t1,
    ov_p27_t2,
    ov_p27_t3,
    ov_p27_t4,
    ov_p28_t1,
    ov_p28_t2,
    ov_p28_t3,
    ov_p28_t4,
    ov_p29_t1,
    ov_p29_t2,
    ov_p29_t3,
    ov_p29_t4,
    ov_p30_t1,
    ov_p30_t2,
    ov_p30_t3,
    ov_p30_t4,
    ov_p31_t1,
    ov_p31_t2,
    ov_p31_t3,
    ov_p31_t4,

   
    o_sync_ok,
    ov_offset_abnormal_cnt,
    ov_offset,
    ov_gm_timestamps,
    ov_correctfield_time,
    ov_mac_time,
    ov_tsc_time,
    ov_sync_link_delay,
    ov_corrent_sync_clk,
    ov_clk_set_time,
    ov_cyclestart_sequenceid,
    ov_tick_length,
    ov_csrateoffset_previousnode

);

input                   i_clk;
input                   i_rst_n;
input                   i_rd;

input       [79:0]      iv_measure_t1;
input       [79:0]      iv_measure_t2;
input       [79:0]      iv_measure_t3;
input       [79:0]      iv_measure_t4;
input                   i_measure_state_wr;
input       [4:0]       iv_timestamps_port_id;
input       [31:0]      iv_port_ptp_enabled;

input                   i_sync_ok;
input       [15:0]      iv_offset_abnormal_cnt;
input       [12:0]      iv_offset;
input                   i_sync_state_wr;
input       [79:0]      iv_gm_timestamps;
input       [63:0]      iv_correctfield_time;
input       [79:0]      iv_mac_time;
input       [79:0]      iv_tsc_time;
input       [27:0]      iv_sync_link_delay;
input       [79:0]      iv_corrent_sync_clk;
input       [95:0]      iv_clk_set_time;
input       [31:0]      iv_cyclestart_sequenceid;
input       [63:0]      iv_tick_length;
input       [31:0]      iv_csrateoffset_previousnode;
input                   i_csrateoffset_previousnode_wr;

output  reg     [79:0]  ov_p0_t1;
output  reg     [79:0]  ov_p0_t2;
output  reg     [79:0]  ov_p0_t3;
output  reg     [79:0]  ov_p0_t4;
output  reg     [79:0]  ov_p1_t1;
output  reg     [79:0]  ov_p1_t2;
output  reg     [79:0]  ov_p1_t3;
output  reg     [79:0]  ov_p1_t4;
output  reg     [79:0]  ov_p2_t1;
output  reg     [79:0]  ov_p2_t2;
output  reg     [79:0]  ov_p2_t3;
output  reg     [79:0]  ov_p2_t4;
output  reg     [79:0]  ov_p3_t1;
output  reg     [79:0]  ov_p3_t2;
output  reg     [79:0]  ov_p3_t3;
output  reg     [79:0]  ov_p3_t4;
output  reg     [79:0]  ov_p4_t1;
output  reg     [79:0]  ov_p4_t2;
output  reg     [79:0]  ov_p4_t3;
output  reg     [79:0]  ov_p4_t4;
output  reg     [79:0]  ov_p5_t1;
output  reg     [79:0]  ov_p5_t2;
output  reg     [79:0]  ov_p5_t3;
output  reg     [79:0]  ov_p5_t4;
output  reg     [79:0]  ov_p6_t1;
output  reg     [79:0]  ov_p6_t2;
output  reg     [79:0]  ov_p6_t3;
output  reg     [79:0]  ov_p6_t4;
output  reg     [79:0]  ov_p7_t1;
output  reg     [79:0]  ov_p7_t2;
output  reg     [79:0]  ov_p7_t3;
output  reg     [79:0]  ov_p7_t4;
output  reg     [79:0]  ov_p8_t1;
output  reg     [79:0]  ov_p8_t2;
output  reg     [79:0]  ov_p8_t3;
output  reg     [79:0]  ov_p8_t4;
output  reg     [79:0]  ov_p9_t1;
output  reg     [79:0]  ov_p9_t2;
output  reg     [79:0]  ov_p9_t3;
output  reg     [79:0]  ov_p9_t4;
output  reg     [79:0]  ov_p10_t1;
output  reg     [79:0]  ov_p10_t2;
output  reg     [79:0]  ov_p10_t3;
output  reg     [79:0]  ov_p10_t4;
output  reg     [79:0]  ov_p11_t1;
output  reg     [79:0]  ov_p11_t2;
output  reg     [79:0]  ov_p11_t3;
output  reg     [79:0]  ov_p11_t4;
output  reg     [79:0]  ov_p12_t1;
output  reg     [79:0]  ov_p12_t2;
output  reg     [79:0]  ov_p12_t3;
output  reg     [79:0]  ov_p12_t4;
output  reg     [79:0]  ov_p13_t1;
output  reg     [79:0]  ov_p13_t2;
output  reg     [79:0]  ov_p13_t3;
output  reg     [79:0]  ov_p13_t4;
output  reg     [79:0]  ov_p14_t1;
output  reg     [79:0]  ov_p14_t2;
output  reg     [79:0]  ov_p14_t3;
output  reg     [79:0]  ov_p14_t4;
output  reg     [79:0]  ov_p15_t1;
output  reg     [79:0]  ov_p15_t2;
output  reg     [79:0]  ov_p15_t3;
output  reg     [79:0]  ov_p15_t4;
output  reg     [79:0]  ov_p16_t1;
output  reg     [79:0]  ov_p16_t2;
output  reg     [79:0]  ov_p16_t3;
output  reg     [79:0]  ov_p16_t4;
output  reg     [79:0]  ov_p17_t1;
output  reg     [79:0]  ov_p17_t2;
output  reg     [79:0]  ov_p17_t3;
output  reg     [79:0]  ov_p17_t4;
output  reg     [79:0]  ov_p18_t1;
output  reg     [79:0]  ov_p18_t2;
output  reg     [79:0]  ov_p18_t3;
output  reg     [79:0]  ov_p18_t4;
output  reg     [79:0]  ov_p19_t1;
output  reg     [79:0]  ov_p19_t2;
output  reg     [79:0]  ov_p19_t3;
output  reg     [79:0]  ov_p19_t4;
output  reg     [79:0]  ov_p20_t1;
output  reg     [79:0]  ov_p20_t2;
output  reg     [79:0]  ov_p20_t3;
output  reg     [79:0]  ov_p20_t4;
output  reg     [79:0]  ov_p21_t1;
output  reg     [79:0]  ov_p21_t2;
output  reg     [79:0]  ov_p21_t3;
output  reg     [79:0]  ov_p21_t4;
output  reg     [79:0]  ov_p22_t1;
output  reg     [79:0]  ov_p22_t2;
output  reg     [79:0]  ov_p22_t3;
output  reg     [79:0]  ov_p22_t4;
output  reg     [79:0]  ov_p23_t1;
output  reg     [79:0]  ov_p23_t2;
output  reg     [79:0]  ov_p23_t3;
output  reg     [79:0]  ov_p23_t4;
output  reg     [79:0]  ov_p24_t1;
output  reg     [79:0]  ov_p24_t2;
output  reg     [79:0]  ov_p24_t3;
output  reg     [79:0]  ov_p24_t4;
output  reg     [79:0]  ov_p25_t1;
output  reg     [79:0]  ov_p25_t2;
output  reg     [79:0]  ov_p25_t3;
output  reg     [79:0]  ov_p25_t4;
output  reg     [79:0]  ov_p26_t1;
output  reg     [79:0]  ov_p26_t2;
output  reg     [79:0]  ov_p26_t3;
output  reg     [79:0]  ov_p26_t4;
output  reg     [79:0]  ov_p27_t1;
output  reg     [79:0]  ov_p27_t2;
output  reg     [79:0]  ov_p27_t3;
output  reg     [79:0]  ov_p27_t4;
output  reg     [79:0]  ov_p28_t1;
output  reg     [79:0]  ov_p28_t2;
output  reg     [79:0]  ov_p28_t3;
output  reg     [79:0]  ov_p28_t4;
output  reg     [79:0]  ov_p29_t1;
output  reg     [79:0]  ov_p29_t2;
output  reg     [79:0]  ov_p29_t3;
output  reg     [79:0]  ov_p29_t4;
output  reg     [79:0]  ov_p30_t1;
output  reg     [79:0]  ov_p30_t2;
output  reg     [79:0]  ov_p30_t3;
output  reg     [79:0]  ov_p30_t4;
output  reg     [79:0]  ov_p31_t1;
output  reg     [79:0]  ov_p31_t2;
output  reg     [79:0]  ov_p31_t3;
output  reg     [79:0]  ov_p31_t4;

output  reg             o_sync_ok;
output  reg     [15:0]  ov_offset_abnormal_cnt;
output  reg     [12:0]  ov_offset;
output  reg     [79:0]  ov_gm_timestamps;
output  reg     [63:0]  ov_correctfield_time;
output  reg     [79:0]  ov_mac_time;
output  reg     [79:0]  ov_tsc_time;
output  reg     [11:0]  ov_sync_link_delay;
output  reg     [79:0]  ov_corrent_sync_clk;
output  reg     [79:0]  ov_clk_set_time;
output  reg     [31:0]  ov_cyclestart_sequenceid;
output  reg     [63:0]  ov_tick_length;
output  reg     [31:0]  ov_csrateoffset_previousnode;

reg             [79:0]  rv_p0_t1_reg;
reg             [79:0]  rv_p0_t2_reg;
reg             [79:0]  rv_p0_t3_reg;
reg             [79:0]  rv_p0_t4_reg;
reg             [79:0]  rv_p1_t1_reg;
reg             [79:0]  rv_p1_t2_reg;
reg             [79:0]  rv_p1_t3_reg;
reg             [79:0]  rv_p1_t4_reg;
reg             [79:0]  rv_p2_t1_reg;
reg             [79:0]  rv_p2_t2_reg;
reg             [79:0]  rv_p2_t3_reg;
reg             [79:0]  rv_p2_t4_reg;
reg             [79:0]  rv_p3_t1_reg;
reg             [79:0]  rv_p3_t2_reg;
reg             [79:0]  rv_p3_t3_reg;
reg             [79:0]  rv_p3_t4_reg;
reg             [79:0]  rv_p4_t1_reg;
reg             [79:0]  rv_p4_t2_reg;
reg             [79:0]  rv_p4_t3_reg;
reg             [79:0]  rv_p4_t4_reg;
reg             [79:0]  rv_p5_t1_reg;
reg             [79:0]  rv_p5_t2_reg;
reg             [79:0]  rv_p5_t3_reg;
reg             [79:0]  rv_p5_t4_reg;
reg             [79:0]  rv_p6_t1_reg;
reg             [79:0]  rv_p6_t2_reg;
reg             [79:0]  rv_p6_t3_reg;
reg             [79:0]  rv_p6_t4_reg;
reg             [79:0]  rv_p7_t1_reg;
reg             [79:0]  rv_p7_t2_reg;
reg             [79:0]  rv_p7_t3_reg;
reg             [79:0]  rv_p7_t4_reg;
reg             [79:0]  rv_p8_t1_reg;
reg             [79:0]  rv_p8_t2_reg;
reg             [79:0]  rv_p8_t3_reg;
reg             [79:0]  rv_p8_t4_reg;
reg             [79:0]  rv_p9_t1_reg;
reg             [79:0]  rv_p9_t2_reg;
reg             [79:0]  rv_p9_t3_reg;
reg             [79:0]  rv_p9_t4_reg;
reg             [79:0]  rv_p10_t1_reg;
reg             [79:0]  rv_p10_t2_reg;
reg             [79:0]  rv_p10_t3_reg;
reg             [79:0]  rv_p10_t4_reg;
reg             [79:0]  rv_p11_t1_reg;
reg             [79:0]  rv_p11_t2_reg;
reg             [79:0]  rv_p11_t3_reg;
reg             [79:0]  rv_p11_t4_reg;
reg             [79:0]  rv_p12_t1_reg;
reg             [79:0]  rv_p12_t2_reg;
reg             [79:0]  rv_p12_t3_reg;
reg             [79:0]  rv_p12_t4_reg;
reg             [79:0]  rv_p13_t1_reg;
reg             [79:0]  rv_p13_t2_reg;
reg             [79:0]  rv_p13_t3_reg;
reg             [79:0]  rv_p13_t4_reg;
reg             [79:0]  rv_p14_t1_reg;
reg             [79:0]  rv_p14_t2_reg;
reg             [79:0]  rv_p14_t3_reg;
reg             [79:0]  rv_p14_t4_reg;
reg             [79:0]  rv_p15_t1_reg;
reg             [79:0]  rv_p15_t2_reg;
reg             [79:0]  rv_p15_t3_reg;
reg             [79:0]  rv_p15_t4_reg;
reg             [79:0]  rv_p16_t1_reg;
reg             [79:0]  rv_p16_t2_reg;
reg             [79:0]  rv_p16_t3_reg;
reg             [79:0]  rv_p16_t4_reg;
reg             [79:0]  rv_p17_t1_reg;
reg             [79:0]  rv_p17_t2_reg;
reg             [79:0]  rv_p17_t3_reg;
reg             [79:0]  rv_p17_t4_reg;
reg             [79:0]  rv_p18_t1_reg;
reg             [79:0]  rv_p18_t2_reg;
reg             [79:0]  rv_p18_t3_reg;
reg             [79:0]  rv_p18_t4_reg;
reg             [79:0]  rv_p19_t1_reg;
reg             [79:0]  rv_p19_t2_reg;
reg             [79:0]  rv_p19_t3_reg;
reg             [79:0]  rv_p19_t4_reg;
reg             [79:0]  rv_p20_t1_reg;
reg             [79:0]  rv_p20_t2_reg;
reg             [79:0]  rv_p20_t3_reg;
reg             [79:0]  rv_p20_t4_reg;
reg             [79:0]  rv_p21_t1_reg;
reg             [79:0]  rv_p21_t2_reg;
reg             [79:0]  rv_p21_t3_reg;
reg             [79:0]  rv_p21_t4_reg;
reg             [79:0]  rv_p22_t1_reg;
reg             [79:0]  rv_p22_t2_reg;
reg             [79:0]  rv_p22_t3_reg;
reg             [79:0]  rv_p22_t4_reg;
reg             [79:0]  rv_p23_t1_reg;
reg             [79:0]  rv_p23_t2_reg;
reg             [79:0]  rv_p23_t3_reg;
reg             [79:0]  rv_p23_t4_reg;
reg             [79:0]  rv_p24_t1_reg;
reg             [79:0]  rv_p24_t2_reg;
reg             [79:0]  rv_p24_t3_reg;
reg             [79:0]  rv_p24_t4_reg;
reg             [79:0]  rv_p25_t1_reg;
reg             [79:0]  rv_p25_t2_reg;
reg             [79:0]  rv_p25_t3_reg;
reg             [79:0]  rv_p25_t4_reg;
reg             [79:0]  rv_p26_t1_reg;
reg             [79:0]  rv_p26_t2_reg;
reg             [79:0]  rv_p26_t3_reg;
reg             [79:0]  rv_p26_t4_reg;
reg             [79:0]  rv_p27_t1_reg;
reg             [79:0]  rv_p27_t2_reg;
reg             [79:0]  rv_p27_t3_reg;
reg             [79:0]  rv_p27_t4_reg;
reg             [79:0]  rv_p28_t1_reg;
reg             [79:0]  rv_p28_t2_reg;
reg             [79:0]  rv_p28_t3_reg;
reg             [79:0]  rv_p28_t4_reg;
reg             [79:0]  rv_p29_t1_reg;
reg             [79:0]  rv_p29_t2_reg;
reg             [79:0]  rv_p29_t3_reg;
reg             [79:0]  rv_p29_t4_reg;
reg             [79:0]  rv_p30_t1_reg;
reg             [79:0]  rv_p30_t2_reg;
reg             [79:0]  rv_p30_t3_reg;
reg             [79:0]  rv_p30_t4_reg;
reg             [79:0]  rv_p31_t1_reg;
reg             [79:0]  rv_p31_t2_reg;
reg             [79:0]  rv_p31_t3_reg;
reg             [79:0]  rv_p31_t4_reg;

reg                     r_sync_ok_reg;
reg             [15:0]  rv_offset_abnormal_cnt_reg;
reg             [12:0]  rv_offset_reg;
reg             [79:0]  rv_gm_timestamps_reg;
reg             [63:0]  rv_correctfield_time_reg;
reg             [79:0]  rv_mac_time_reg;
reg             [79:0]  rv_tsc_time_reg;
reg             [11:0]  rv_sync_link_delay_reg;
reg             [79:0]  rv_corrent_sync_clk_reg;
reg             [79:0]  rv_clk_set_time_reg;
reg             [31:0]  rv_cyclestart_sequenceid_reg;
reg             [63:0]  rv_tick_length_reg;
reg             [31:0]  rv_csrateoffset_previousnode_reg;

reg             [31:0]  rv_port_reg;
reg                     r_data_reg_flag;
reg                     r_sync_state_wr_reg1;
wire                    w_sync_state_rise;
wire                    w_sync_state_fall;    
// measure state cache
always @(posedge i_clk or negedge i_rst_n) 
    if(~i_rst_n)
        rv_port_reg                         <=  32'd0;
    else if((r_data_reg_flag == 1'b1) )//&& (i_measure_state_wr == 1'b0))
        rv_port_reg                         <=  32'd0;
    else if(i_measure_state_wr == 1'b1)
        rv_port_reg[iv_timestamps_port_id]  <=  1'b1;
    else
        rv_port_reg                         <=  rv_port_reg;

always @(posedge i_clk or negedge i_rst_n) 
    if(~i_rst_n)
        r_data_reg_flag                     <=  1'b0;
    else if((rv_port_reg == iv_port_ptp_enabled) && (i_measure_state_wr  == 1'b0))
        r_data_reg_flag                     <=  1'b1;
    else
        r_data_reg_flag                     <=  1'b0;

always @(posedge i_clk or negedge i_rst_n) 
    if(~i_rst_n)begin
        rv_p0_t1_reg                        <=  80'd0;
        rv_p0_t2_reg                        <=  80'd0;
        rv_p0_t3_reg                        <=  80'd0;
        rv_p0_t4_reg                        <=  80'd0;
        rv_p1_t1_reg                        <=  80'd0;
        rv_p1_t2_reg                        <=  80'd0;
        rv_p1_t3_reg                        <=  80'd0;
        rv_p1_t4_reg                        <=  80'd0;
        rv_p2_t1_reg                        <=  80'd0;
        rv_p2_t2_reg                        <=  80'd0;
        rv_p2_t3_reg                        <=  80'd0;
        rv_p2_t4_reg                        <=  80'd0;
        rv_p3_t1_reg                        <=  80'd0;
        rv_p3_t2_reg                        <=  80'd0;
        rv_p3_t3_reg                        <=  80'd0;
        rv_p3_t4_reg                        <=  80'd0;
        rv_p4_t1_reg                        <=  80'd0;
        rv_p4_t2_reg                        <=  80'd0;
        rv_p4_t3_reg                        <=  80'd0;
        rv_p4_t4_reg                        <=  80'd0;
        rv_p5_t1_reg                        <=  80'd0;
        rv_p5_t2_reg                        <=  80'd0;
        rv_p5_t3_reg                        <=  80'd0;
        rv_p5_t4_reg                        <=  80'd0;
        rv_p6_t1_reg                        <=  80'd0;
        rv_p6_t2_reg                        <=  80'd0;
        rv_p6_t3_reg                        <=  80'd0;
        rv_p6_t4_reg                        <=  80'd0;
        rv_p7_t1_reg                        <=  80'd0;
        rv_p7_t2_reg                        <=  80'd0;
        rv_p7_t3_reg                        <=  80'd0;
        rv_p7_t4_reg                        <=  80'd0;
        rv_p8_t1_reg                        <=  80'd0;
        rv_p8_t2_reg                        <=  80'd0;
        rv_p8_t3_reg                        <=  80'd0;
        rv_p8_t4_reg                        <=  80'd0;
        rv_p9_t1_reg                        <=  80'd0;
        rv_p9_t2_reg                        <=  80'd0;
        rv_p9_t3_reg                        <=  80'd0;
        rv_p9_t4_reg                        <=  80'd0;
        rv_p10_t1_reg                       <=  80'd0;
        rv_p10_t2_reg                       <=  80'd0;
        rv_p10_t3_reg                       <=  80'd0;
        rv_p10_t4_reg                       <=  80'd0;
        rv_p11_t1_reg                       <=  80'd0;
        rv_p11_t2_reg                       <=  80'd0;
        rv_p11_t3_reg                       <=  80'd0;
        rv_p11_t4_reg                       <=  80'd0;
        rv_p12_t1_reg                       <=  80'd0;
        rv_p12_t2_reg                       <=  80'd0;
        rv_p12_t3_reg                       <=  80'd0;
        rv_p12_t4_reg                       <=  80'd0;
        rv_p13_t1_reg                       <=  80'd0;
        rv_p13_t2_reg                       <=  80'd0;
        rv_p13_t3_reg                       <=  80'd0;
        rv_p13_t4_reg                       <=  80'd0;
        rv_p14_t1_reg                       <=  80'd0;
        rv_p14_t2_reg                       <=  80'd0;
        rv_p14_t3_reg                       <=  80'd0;
        rv_p14_t4_reg                       <=  80'd0;
        rv_p15_t1_reg                       <=  80'd0;
        rv_p15_t2_reg                       <=  80'd0;
        rv_p15_t3_reg                       <=  80'd0;
        rv_p15_t4_reg                       <=  80'd0;
        rv_p16_t1_reg                       <=  80'd0;
        rv_p16_t2_reg                       <=  80'd0;
        rv_p16_t3_reg                       <=  80'd0;
        rv_p16_t4_reg                       <=  80'd0;
        rv_p17_t1_reg                       <=  80'd0;
        rv_p17_t2_reg                       <=  80'd0;
        rv_p17_t3_reg                       <=  80'd0;
        rv_p17_t4_reg                       <=  80'd0;
        rv_p18_t1_reg                       <=  80'd0;
        rv_p18_t2_reg                       <=  80'd0;
        rv_p18_t3_reg                       <=  80'd0;
        rv_p18_t4_reg                       <=  80'd0;
        rv_p19_t1_reg                       <=  80'd0;
        rv_p19_t2_reg                       <=  80'd0;
        rv_p19_t3_reg                       <=  80'd0;
        rv_p19_t4_reg                       <=  80'd0;
        rv_p20_t1_reg                       <=  80'd0;
        rv_p20_t2_reg                       <=  80'd0;
        rv_p20_t3_reg                       <=  80'd0;
        rv_p20_t4_reg                       <=  80'd0;
        rv_p21_t1_reg                       <=  80'd0;
        rv_p21_t2_reg                       <=  80'd0;
        rv_p21_t3_reg                       <=  80'd0;
        rv_p21_t4_reg                       <=  80'd0;
        rv_p22_t1_reg                       <=  80'd0;
        rv_p22_t2_reg                       <=  80'd0;
        rv_p22_t3_reg                       <=  80'd0;
        rv_p22_t4_reg                       <=  80'd0;
        rv_p23_t1_reg                       <=  80'd0;
        rv_p23_t2_reg                       <=  80'd0;
        rv_p23_t3_reg                       <=  80'd0;
        rv_p23_t4_reg                       <=  80'd0;
        rv_p24_t1_reg                       <=  80'd0;
        rv_p24_t2_reg                       <=  80'd0;
        rv_p24_t3_reg                       <=  80'd0;
        rv_p24_t4_reg                       <=  80'd0;
        rv_p25_t1_reg                       <=  80'd0;
        rv_p25_t2_reg                       <=  80'd0;
        rv_p25_t3_reg                       <=  80'd0;
        rv_p25_t4_reg                       <=  80'd0;
        rv_p26_t1_reg                       <=  80'd0;
        rv_p26_t2_reg                       <=  80'd0;
        rv_p26_t3_reg                       <=  80'd0;
        rv_p26_t4_reg                       <=  80'd0;
        rv_p27_t1_reg                       <=  80'd0;
        rv_p27_t2_reg                       <=  80'd0;
        rv_p27_t3_reg                       <=  80'd0;
        rv_p27_t4_reg                       <=  80'd0;
        rv_p28_t1_reg                       <=  80'd0;
        rv_p28_t2_reg                       <=  80'd0;
        rv_p28_t3_reg                       <=  80'd0;
        rv_p28_t4_reg                       <=  80'd0;
        rv_p29_t1_reg                       <=  80'd0;
        rv_p29_t2_reg                       <=  80'd0;
        rv_p29_t3_reg                       <=  80'd0;
        rv_p29_t4_reg                       <=  80'd0;
        rv_p30_t1_reg                       <=  80'd0;
        rv_p30_t2_reg                       <=  80'd0;
        rv_p30_t3_reg                       <=  80'd0;
        rv_p30_t4_reg                       <=  80'd0;
        rv_p31_t1_reg                       <=  80'd0;
        rv_p31_t2_reg                       <=  80'd0;
        rv_p31_t3_reg                       <=  80'd0;
        rv_p31_t4_reg                       <=  80'd0;
    end
    else if(i_measure_state_wr == 1'b1)begin
        case (iv_timestamps_port_id)
            5'd0:begin
                    rv_p0_t1_reg            <=  iv_measure_t1;
                    rv_p0_t2_reg            <=  iv_measure_t2;
                    rv_p0_t3_reg            <=  iv_measure_t3;
                    rv_p0_t4_reg            <=  iv_measure_t4;
                end
            5'd1:begin
                    rv_p1_t1_reg            <=  iv_measure_t1;
                    rv_p1_t2_reg            <=  iv_measure_t2;
                    rv_p1_t3_reg            <=  iv_measure_t3;
                    rv_p1_t4_reg            <=  iv_measure_t4;
                end
            5'd2:begin
                    rv_p2_t1_reg            <=  iv_measure_t1;
                    rv_p2_t2_reg            <=  iv_measure_t2;
                    rv_p2_t3_reg            <=  iv_measure_t3;
                    rv_p2_t4_reg            <=  iv_measure_t4;
                end
            5'd3:begin
                    rv_p3_t1_reg            <=  iv_measure_t1;
                    rv_p3_t2_reg            <=  iv_measure_t2;
                    rv_p3_t3_reg            <=  iv_measure_t3;
                    rv_p3_t4_reg            <=  iv_measure_t4;
                end
            5'd4:begin
                    rv_p4_t1_reg            <=  iv_measure_t1;
                    rv_p4_t2_reg            <=  iv_measure_t2;
                    rv_p4_t3_reg            <=  iv_measure_t3;
                    rv_p4_t4_reg            <=  iv_measure_t4;
                end
            5'd5:begin
                    rv_p5_t1_reg            <=  iv_measure_t1;
                    rv_p5_t2_reg            <=  iv_measure_t2;
                    rv_p5_t3_reg            <=  iv_measure_t3;
                    rv_p5_t4_reg            <=  iv_measure_t4;
                end
            5'd6:begin
                    rv_p6_t1_reg            <=  iv_measure_t1;
                    rv_p6_t2_reg            <=  iv_measure_t2;
                    rv_p6_t3_reg            <=  iv_measure_t3;
                    rv_p6_t4_reg            <=  iv_measure_t4;
                end
            5'd7:begin
                    rv_p7_t1_reg            <=  iv_measure_t1;
                    rv_p7_t2_reg            <=  iv_measure_t2;
                    rv_p7_t3_reg            <=  iv_measure_t3;
                    rv_p7_t4_reg            <=  iv_measure_t4;
                end
            5'd8:begin
                    rv_p8_t1_reg            <=  iv_measure_t1;
                    rv_p8_t2_reg            <=  iv_measure_t2;
                    rv_p8_t3_reg            <=  iv_measure_t3;
                    rv_p8_t4_reg            <=  iv_measure_t4;
                end
            5'd9:begin
                    rv_p9_t1_reg            <=  iv_measure_t1;
                    rv_p9_t2_reg            <=  iv_measure_t2;
                    rv_p9_t3_reg            <=  iv_measure_t3;
                    rv_p9_t4_reg            <=  iv_measure_t4;
                end
            5'd10:begin
                    rv_p10_t1_reg            <=  iv_measure_t1;
                    rv_p10_t2_reg            <=  iv_measure_t2;
                    rv_p10_t3_reg            <=  iv_measure_t3;
                    rv_p10_t4_reg            <=  iv_measure_t4;
                end
            5'd11:begin
                    rv_p11_t1_reg            <=  iv_measure_t1;
                    rv_p11_t2_reg            <=  iv_measure_t2;
                    rv_p11_t3_reg            <=  iv_measure_t3;
                    rv_p11_t4_reg            <=  iv_measure_t4;
                end
            5'd12:begin
                    rv_p12_t1_reg            <=  iv_measure_t1;
                    rv_p12_t2_reg            <=  iv_measure_t2;
                    rv_p12_t3_reg            <=  iv_measure_t3;
                    rv_p12_t4_reg            <=  iv_measure_t4;
                end
            5'd13:begin
                    rv_p13_t1_reg            <=  iv_measure_t1;
                    rv_p13_t2_reg            <=  iv_measure_t2;
                    rv_p13_t3_reg            <=  iv_measure_t3;
                    rv_p13_t4_reg            <=  iv_measure_t4;
                end
            5'd14:begin
                    rv_p14_t1_reg            <=  iv_measure_t1;
                    rv_p14_t2_reg            <=  iv_measure_t2;
                    rv_p14_t3_reg            <=  iv_measure_t3;
                    rv_p14_t4_reg            <=  iv_measure_t4;
                end
            5'd15:begin
                    rv_p15_t1_reg            <=  iv_measure_t1;
                    rv_p15_t2_reg            <=  iv_measure_t2;
                    rv_p15_t3_reg            <=  iv_measure_t3;
                    rv_p15_t4_reg            <=  iv_measure_t4;
                end
            5'd16:begin
                    rv_p16_t1_reg            <=  iv_measure_t1;
                    rv_p16_t2_reg            <=  iv_measure_t2;
                    rv_p16_t3_reg            <=  iv_measure_t3;
                    rv_p16_t4_reg            <=  iv_measure_t4;
                end
            5'd17:begin
                    rv_p17_t1_reg            <=  iv_measure_t1;
                    rv_p17_t2_reg            <=  iv_measure_t2;
                    rv_p17_t3_reg            <=  iv_measure_t3;
                    rv_p17_t4_reg            <=  iv_measure_t4;
                end
            5'd18:begin
                    rv_p18_t1_reg            <=  iv_measure_t1;
                    rv_p18_t2_reg            <=  iv_measure_t2;
                    rv_p18_t3_reg            <=  iv_measure_t3;
                    rv_p18_t4_reg            <=  iv_measure_t4;
                end
            5'd19:begin
                    rv_p19_t1_reg            <=  iv_measure_t1;
                    rv_p19_t2_reg            <=  iv_measure_t2;
                    rv_p19_t3_reg            <=  iv_measure_t3;
                    rv_p19_t4_reg            <=  iv_measure_t4;
                end
            5'd20:begin
                    rv_p20_t1_reg            <=  iv_measure_t1;
                    rv_p20_t2_reg            <=  iv_measure_t2;
                    rv_p20_t3_reg            <=  iv_measure_t3;
                    rv_p20_t4_reg            <=  iv_measure_t4;
                end
            5'd21:begin
                    rv_p21_t1_reg            <=  iv_measure_t1;
                    rv_p21_t2_reg            <=  iv_measure_t2;
                    rv_p21_t3_reg            <=  iv_measure_t3;
                    rv_p21_t4_reg            <=  iv_measure_t4;
                end
            5'd22:begin
                    rv_p22_t1_reg            <=  iv_measure_t1;
                    rv_p22_t2_reg            <=  iv_measure_t2;
                    rv_p22_t3_reg            <=  iv_measure_t3;
                    rv_p22_t4_reg            <=  iv_measure_t4;
                end
            5'd23:begin
                    rv_p23_t1_reg            <=  iv_measure_t1;
                    rv_p23_t2_reg            <=  iv_measure_t2;
                    rv_p23_t3_reg            <=  iv_measure_t3;
                    rv_p23_t4_reg            <=  iv_measure_t4;
                end
            5'd24:begin
                    rv_p24_t1_reg            <=  iv_measure_t1;
                    rv_p24_t2_reg            <=  iv_measure_t2;
                    rv_p24_t3_reg            <=  iv_measure_t3;
                    rv_p24_t4_reg            <=  iv_measure_t4;
                end
            5'd25:begin
                    rv_p25_t1_reg            <=  iv_measure_t1;
                    rv_p25_t2_reg            <=  iv_measure_t2;
                    rv_p25_t3_reg            <=  iv_measure_t3;
                    rv_p25_t4_reg            <=  iv_measure_t4;
                end
            5'd26:begin
                    rv_p26_t1_reg            <=  iv_measure_t1;
                    rv_p26_t2_reg            <=  iv_measure_t2;
                    rv_p26_t3_reg            <=  iv_measure_t3;
                    rv_p26_t4_reg            <=  iv_measure_t4;
                end
            5'd27:begin
                    rv_p27_t1_reg            <=  iv_measure_t1;
                    rv_p27_t2_reg            <=  iv_measure_t2;
                    rv_p27_t3_reg            <=  iv_measure_t3;
                    rv_p27_t4_reg            <=  iv_measure_t4;
                end
            5'd28:begin
                    rv_p28_t1_reg            <=  iv_measure_t1;
                    rv_p28_t2_reg            <=  iv_measure_t2;
                    rv_p28_t3_reg            <=  iv_measure_t3;
                    rv_p28_t4_reg            <=  iv_measure_t4;
                end
            5'd29:begin
                    rv_p29_t1_reg            <=  iv_measure_t1;
                    rv_p29_t2_reg            <=  iv_measure_t2;
                    rv_p29_t3_reg            <=  iv_measure_t3;
                    rv_p29_t4_reg            <=  iv_measure_t4;
                end
            5'd30:begin
                    rv_p30_t1_reg            <=  iv_measure_t1;
                    rv_p30_t2_reg            <=  iv_measure_t2;
                    rv_p30_t3_reg            <=  iv_measure_t3;
                    rv_p30_t4_reg            <=  iv_measure_t4;
                end
            5'd31:begin
                    rv_p31_t1_reg            <=  iv_measure_t1;
                    rv_p31_t2_reg            <=  iv_measure_t2;
                    rv_p31_t3_reg            <=  iv_measure_t3;
                    rv_p31_t4_reg            <=  iv_measure_t4;
                end
            default: begin
                    rv_p0_t1_reg             <=  80'd0;
                    rv_p0_t2_reg             <=  80'd0;
                    rv_p0_t3_reg             <=  80'd0;
                    rv_p0_t4_reg             <=  80'd0;
                    rv_p1_t1_reg             <=  80'd0;
                    rv_p1_t2_reg             <=  80'd0;
                    rv_p1_t3_reg             <=  80'd0;
                    rv_p1_t4_reg             <=  80'd0;
                    rv_p2_t1_reg             <=  80'd0;
                    rv_p2_t2_reg             <=  80'd0;
                    rv_p2_t3_reg             <=  80'd0;
                    rv_p2_t4_reg             <=  80'd0;
                    rv_p3_t1_reg             <=  80'd0;
                    rv_p3_t2_reg             <=  80'd0;
                    rv_p3_t3_reg             <=  80'd0;
                    rv_p3_t4_reg             <=  80'd0;
                    rv_p4_t1_reg             <=  80'd0;
                    rv_p4_t2_reg             <=  80'd0;
                    rv_p4_t3_reg             <=  80'd0;
                    rv_p4_t4_reg             <=  80'd0;
                    rv_p5_t1_reg             <=  80'd0;
                    rv_p5_t2_reg             <=  80'd0;
                    rv_p5_t3_reg             <=  80'd0;
                    rv_p5_t4_reg             <=  80'd0;
                    rv_p6_t1_reg             <=  80'd0;
                    rv_p6_t2_reg             <=  80'd0;
                    rv_p6_t3_reg             <=  80'd0;
                    rv_p6_t4_reg             <=  80'd0;
                    rv_p7_t1_reg             <=  80'd0;
                    rv_p7_t2_reg             <=  80'd0;
                    rv_p7_t3_reg             <=  80'd0;
                    rv_p7_t4_reg             <=  80'd0;
                    rv_p8_t1_reg             <=  80'd0;
                    rv_p8_t2_reg             <=  80'd0;
                    rv_p8_t3_reg             <=  80'd0;
                    rv_p8_t4_reg             <=  80'd0;
                    rv_p9_t1_reg             <=  80'd0;
                    rv_p9_t2_reg             <=  80'd0;
                    rv_p9_t3_reg             <=  80'd0;
                    rv_p9_t4_reg             <=  80'd0;
                    rv_p10_t1_reg            <=  80'd0;
                    rv_p10_t2_reg            <=  80'd0;
                    rv_p10_t3_reg            <=  80'd0;
                    rv_p10_t4_reg            <=  80'd0;
                    rv_p11_t1_reg            <=  80'd0;
                    rv_p11_t2_reg            <=  80'd0;
                    rv_p11_t3_reg            <=  80'd0;
                    rv_p11_t4_reg            <=  80'd0;
                    rv_p12_t1_reg            <=  80'd0;
                    rv_p12_t2_reg            <=  80'd0;
                    rv_p12_t3_reg            <=  80'd0;
                    rv_p12_t4_reg            <=  80'd0;
                    rv_p13_t1_reg            <=  80'd0;
                    rv_p13_t2_reg            <=  80'd0;
                    rv_p13_t3_reg            <=  80'd0;
                    rv_p13_t4_reg            <=  80'd0;
                    rv_p14_t1_reg            <=  80'd0;
                    rv_p14_t2_reg            <=  80'd0;
                    rv_p14_t3_reg            <=  80'd0;
                    rv_p14_t4_reg            <=  80'd0;
                    rv_p15_t1_reg            <=  80'd0;
                    rv_p15_t2_reg            <=  80'd0;
                    rv_p15_t3_reg            <=  80'd0;
                    rv_p15_t4_reg            <=  80'd0;
                    rv_p16_t1_reg            <=  80'd0;
                    rv_p16_t2_reg            <=  80'd0;
                    rv_p16_t3_reg            <=  80'd0;
                    rv_p16_t4_reg            <=  80'd0;
                    rv_p17_t1_reg            <=  80'd0;
                    rv_p17_t2_reg            <=  80'd0;
                    rv_p17_t3_reg            <=  80'd0;
                    rv_p17_t4_reg            <=  80'd0;
                    rv_p18_t1_reg            <=  80'd0;
                    rv_p18_t2_reg            <=  80'd0;
                    rv_p18_t3_reg            <=  80'd0;
                    rv_p18_t4_reg            <=  80'd0;
                    rv_p19_t1_reg            <=  80'd0;
                    rv_p19_t2_reg            <=  80'd0;
                    rv_p19_t3_reg            <=  80'd0;
                    rv_p19_t4_reg            <=  80'd0;
                    rv_p20_t1_reg            <=  80'd0;
                    rv_p20_t2_reg            <=  80'd0;
                    rv_p20_t3_reg            <=  80'd0;
                    rv_p20_t4_reg            <=  80'd0;
                    rv_p21_t1_reg            <=  80'd0;
                    rv_p21_t2_reg            <=  80'd0;
                    rv_p21_t3_reg            <=  80'd0;
                    rv_p21_t4_reg            <=  80'd0;
                    rv_p22_t1_reg            <=  80'd0;
                    rv_p22_t2_reg            <=  80'd0;
                    rv_p22_t3_reg            <=  80'd0;
                    rv_p22_t4_reg            <=  80'd0;
                    rv_p23_t1_reg            <=  80'd0;
                    rv_p23_t2_reg            <=  80'd0;
                    rv_p23_t3_reg            <=  80'd0;
                    rv_p23_t4_reg            <=  80'd0;
                    rv_p24_t1_reg            <=  80'd0;
                    rv_p24_t2_reg            <=  80'd0;
                    rv_p24_t3_reg            <=  80'd0;
                    rv_p24_t4_reg            <=  80'd0;
                    rv_p25_t1_reg            <=  80'd0;
                    rv_p25_t2_reg            <=  80'd0;
                    rv_p25_t3_reg            <=  80'd0;
                    rv_p25_t4_reg            <=  80'd0;
                    rv_p26_t1_reg            <=  80'd0;
                    rv_p26_t2_reg            <=  80'd0;
                    rv_p26_t3_reg            <=  80'd0;
                    rv_p26_t4_reg            <=  80'd0;
                    rv_p27_t1_reg            <=  80'd0;
                    rv_p27_t2_reg            <=  80'd0;
                    rv_p27_t3_reg            <=  80'd0;
                    rv_p27_t4_reg            <=  80'd0;
                    rv_p28_t1_reg            <=  80'd0;
                    rv_p28_t2_reg            <=  80'd0;
                    rv_p28_t3_reg            <=  80'd0;
                    rv_p28_t4_reg            <=  80'd0;
                    rv_p29_t1_reg            <=  80'd0;
                    rv_p29_t2_reg            <=  80'd0;
                    rv_p29_t3_reg            <=  80'd0;
                    rv_p29_t4_reg            <=  80'd0;
                    rv_p30_t1_reg            <=  80'd0;
                    rv_p30_t2_reg            <=  80'd0;
                    rv_p30_t3_reg            <=  80'd0;
                    rv_p30_t4_reg            <=  80'd0;
                    rv_p31_t1_reg            <=  80'd0;
                    rv_p31_t2_reg            <=  80'd0;
                    rv_p31_t3_reg            <=  80'd0;
                    rv_p31_t4_reg            <=  80'd0;
            end
        endcase
    end
    else if((r_data_reg_flag == 1'b1) && (i_measure_state_wr == 1'b0))begin
        rv_p0_t1_reg             <=  80'd0;
        rv_p0_t2_reg             <=  80'd0;
        rv_p0_t3_reg             <=  80'd0;
        rv_p0_t4_reg             <=  80'd0;
        rv_p1_t1_reg             <=  80'd0;
        rv_p1_t2_reg             <=  80'd0;
        rv_p1_t3_reg             <=  80'd0;
        rv_p1_t4_reg             <=  80'd0;
        rv_p2_t1_reg             <=  80'd0;
        rv_p2_t2_reg             <=  80'd0;
        rv_p2_t3_reg             <=  80'd0;
        rv_p2_t4_reg             <=  80'd0;
        rv_p3_t1_reg             <=  80'd0;
        rv_p3_t2_reg             <=  80'd0;
        rv_p3_t3_reg             <=  80'd0;
        rv_p3_t4_reg             <=  80'd0;
        rv_p4_t1_reg             <=  80'd0;
        rv_p4_t2_reg             <=  80'd0;
        rv_p4_t3_reg             <=  80'd0;
        rv_p4_t4_reg             <=  80'd0;
        rv_p5_t1_reg             <=  80'd0;
        rv_p5_t2_reg             <=  80'd0;
        rv_p5_t3_reg             <=  80'd0;
        rv_p5_t4_reg             <=  80'd0;
        rv_p6_t1_reg             <=  80'd0;
        rv_p6_t2_reg             <=  80'd0;
        rv_p6_t3_reg             <=  80'd0;
        rv_p6_t4_reg             <=  80'd0;
        rv_p7_t1_reg             <=  80'd0;
        rv_p7_t2_reg             <=  80'd0;
        rv_p7_t3_reg             <=  80'd0;
        rv_p7_t4_reg             <=  80'd0;
        rv_p8_t1_reg             <=  80'd0;
        rv_p8_t2_reg             <=  80'd0;
        rv_p8_t3_reg             <=  80'd0;
        rv_p8_t4_reg             <=  80'd0;
        rv_p9_t1_reg             <=  80'd0;
        rv_p9_t2_reg             <=  80'd0;
        rv_p9_t3_reg             <=  80'd0;
        rv_p9_t4_reg             <=  80'd0;
        rv_p10_t1_reg            <=  80'd0;
        rv_p10_t2_reg            <=  80'd0;
        rv_p10_t3_reg            <=  80'd0;
        rv_p10_t4_reg            <=  80'd0;
        rv_p11_t1_reg            <=  80'd0;
        rv_p11_t2_reg            <=  80'd0;
        rv_p11_t3_reg            <=  80'd0;
        rv_p11_t4_reg            <=  80'd0;
        rv_p12_t1_reg            <=  80'd0;
        rv_p12_t2_reg            <=  80'd0;
        rv_p12_t3_reg            <=  80'd0;
        rv_p12_t4_reg            <=  80'd0;
        rv_p13_t1_reg            <=  80'd0;
        rv_p13_t2_reg            <=  80'd0;
        rv_p13_t3_reg            <=  80'd0;
        rv_p13_t4_reg            <=  80'd0;
        rv_p14_t1_reg            <=  80'd0;
        rv_p14_t2_reg            <=  80'd0;
        rv_p14_t3_reg            <=  80'd0;
        rv_p14_t4_reg            <=  80'd0;
        rv_p15_t1_reg            <=  80'd0;
        rv_p15_t2_reg            <=  80'd0;
        rv_p15_t3_reg            <=  80'd0;
        rv_p15_t4_reg            <=  80'd0;
        rv_p16_t1_reg            <=  80'd0;
        rv_p16_t2_reg            <=  80'd0;
        rv_p16_t3_reg            <=  80'd0;
        rv_p16_t4_reg            <=  80'd0;
        rv_p17_t1_reg            <=  80'd0;
        rv_p17_t2_reg            <=  80'd0;
        rv_p17_t3_reg            <=  80'd0;
        rv_p17_t4_reg            <=  80'd0;
        rv_p18_t1_reg            <=  80'd0;
        rv_p18_t2_reg            <=  80'd0;
        rv_p18_t3_reg            <=  80'd0;
        rv_p18_t4_reg            <=  80'd0;
        rv_p19_t1_reg            <=  80'd0;
        rv_p19_t2_reg            <=  80'd0;
        rv_p19_t3_reg            <=  80'd0;
        rv_p19_t4_reg            <=  80'd0;
        rv_p20_t1_reg            <=  80'd0;
        rv_p20_t2_reg            <=  80'd0;
        rv_p20_t3_reg            <=  80'd0;
        rv_p20_t4_reg            <=  80'd0;
        rv_p21_t1_reg            <=  80'd0;
        rv_p21_t2_reg            <=  80'd0;
        rv_p21_t3_reg            <=  80'd0;
        rv_p21_t4_reg            <=  80'd0;
        rv_p22_t1_reg            <=  80'd0;
        rv_p22_t2_reg            <=  80'd0;
        rv_p22_t3_reg            <=  80'd0;
        rv_p22_t4_reg            <=  80'd0;
        rv_p23_t1_reg            <=  80'd0;
        rv_p23_t2_reg            <=  80'd0;
        rv_p23_t3_reg            <=  80'd0;
        rv_p23_t4_reg            <=  80'd0;
        rv_p24_t1_reg            <=  80'd0;
        rv_p24_t2_reg            <=  80'd0;
        rv_p24_t3_reg            <=  80'd0;
        rv_p24_t4_reg            <=  80'd0;
        rv_p25_t1_reg            <=  80'd0;
        rv_p25_t2_reg            <=  80'd0;
        rv_p25_t3_reg            <=  80'd0;
        rv_p25_t4_reg            <=  80'd0;
        rv_p26_t1_reg            <=  80'd0;
        rv_p26_t2_reg            <=  80'd0;
        rv_p26_t3_reg            <=  80'd0;
        rv_p26_t4_reg            <=  80'd0;
        rv_p27_t1_reg            <=  80'd0;
        rv_p27_t2_reg            <=  80'd0;
        rv_p27_t3_reg            <=  80'd0;
        rv_p27_t4_reg            <=  80'd0;
        rv_p28_t1_reg            <=  80'd0;
        rv_p28_t2_reg            <=  80'd0;
        rv_p28_t3_reg            <=  80'd0;
        rv_p28_t4_reg            <=  80'd0;
        rv_p29_t1_reg            <=  80'd0;
        rv_p29_t2_reg            <=  80'd0;
        rv_p29_t3_reg            <=  80'd0;
        rv_p29_t4_reg            <=  80'd0;
        rv_p30_t1_reg            <=  80'd0;
        rv_p30_t2_reg            <=  80'd0;
        rv_p30_t3_reg            <=  80'd0;
        rv_p30_t4_reg            <=  80'd0;
        rv_p31_t1_reg            <=  80'd0;
        rv_p31_t2_reg            <=  80'd0;
        rv_p31_t3_reg            <=  80'd0;
        rv_p31_t4_reg            <=  80'd0;  
    end
    else begin
        rv_p0_t1_reg             <=  rv_p0_t1_reg;
        rv_p0_t2_reg             <=  rv_p0_t2_reg;
        rv_p0_t3_reg             <=  rv_p0_t3_reg;
        rv_p0_t4_reg             <=  rv_p0_t4_reg;
        rv_p1_t1_reg             <=  rv_p1_t1_reg;
        rv_p1_t2_reg             <=  rv_p1_t2_reg;
        rv_p1_t3_reg             <=  rv_p1_t3_reg;
        rv_p1_t4_reg             <=  rv_p1_t4_reg;
        rv_p2_t1_reg             <=  rv_p2_t1_reg;
        rv_p2_t2_reg             <=  rv_p2_t2_reg;
        rv_p2_t3_reg             <=  rv_p2_t3_reg;
        rv_p2_t4_reg             <=  rv_p2_t4_reg;
        rv_p3_t1_reg             <=  rv_p3_t1_reg;
        rv_p3_t2_reg             <=  rv_p3_t2_reg;
        rv_p3_t3_reg             <=  rv_p3_t3_reg;
        rv_p3_t4_reg             <=  rv_p3_t4_reg;
        rv_p4_t1_reg             <=  rv_p4_t1_reg;
        rv_p4_t2_reg             <=  rv_p4_t2_reg;
        rv_p4_t3_reg             <=  rv_p4_t3_reg;
        rv_p4_t4_reg             <=  rv_p4_t4_reg;
        rv_p5_t1_reg             <=  rv_p5_t1_reg;
        rv_p5_t2_reg             <=  rv_p5_t2_reg;
        rv_p5_t3_reg             <=  rv_p5_t3_reg;
        rv_p5_t4_reg             <=  rv_p5_t4_reg;
        rv_p6_t1_reg             <=  rv_p6_t1_reg;
        rv_p6_t2_reg             <=  rv_p6_t2_reg;
        rv_p6_t3_reg             <=  rv_p6_t3_reg;
        rv_p6_t4_reg             <=  rv_p6_t4_reg;
        rv_p7_t1_reg             <=  rv_p7_t1_reg;
        rv_p7_t2_reg             <=  rv_p7_t2_reg;
        rv_p7_t3_reg             <=  rv_p7_t3_reg;
        rv_p7_t4_reg             <=  rv_p7_t4_reg;
        rv_p8_t1_reg             <=  rv_p8_t1_reg;
        rv_p8_t2_reg             <=  rv_p8_t2_reg;
        rv_p8_t3_reg             <=  rv_p8_t3_reg;
        rv_p8_t4_reg             <=  rv_p8_t4_reg;
        rv_p9_t1_reg             <=  rv_p9_t1_reg;
        rv_p9_t2_reg             <=  rv_p9_t2_reg;
        rv_p9_t3_reg             <=  rv_p9_t3_reg;
        rv_p9_t4_reg             <=  rv_p9_t4_reg;
        rv_p10_t1_reg            <=  rv_p10_t1_reg;
        rv_p10_t2_reg            <=  rv_p10_t2_reg;
        rv_p10_t3_reg            <=  rv_p10_t3_reg;
        rv_p10_t4_reg            <=  rv_p10_t4_reg;
        rv_p11_t1_reg            <=  rv_p11_t1_reg;
        rv_p11_t2_reg            <=  rv_p11_t2_reg;
        rv_p11_t3_reg            <=  rv_p11_t3_reg;
        rv_p11_t4_reg            <=  rv_p11_t4_reg;
        rv_p12_t1_reg            <=  rv_p12_t1_reg;
        rv_p12_t2_reg            <=  rv_p12_t2_reg;
        rv_p12_t3_reg            <=  rv_p12_t3_reg;
        rv_p12_t4_reg            <=  rv_p12_t4_reg;
        rv_p13_t1_reg            <=  rv_p13_t1_reg;
        rv_p13_t2_reg            <=  rv_p13_t2_reg;
        rv_p13_t3_reg            <=  rv_p13_t3_reg;
        rv_p13_t4_reg            <=  rv_p13_t4_reg;
        rv_p14_t1_reg            <=  rv_p14_t1_reg;
        rv_p14_t2_reg            <=  rv_p14_t2_reg;
        rv_p14_t3_reg            <=  rv_p14_t3_reg;
        rv_p14_t4_reg            <=  rv_p14_t4_reg;
        rv_p15_t1_reg            <=  rv_p15_t1_reg;
        rv_p15_t2_reg            <=  rv_p15_t2_reg;
        rv_p15_t3_reg            <=  rv_p15_t3_reg;
        rv_p15_t4_reg            <=  rv_p15_t4_reg;
        rv_p16_t1_reg            <=  rv_p16_t1_reg;
        rv_p16_t2_reg            <=  rv_p16_t2_reg;
        rv_p16_t3_reg            <=  rv_p16_t3_reg;
        rv_p16_t4_reg            <=  rv_p16_t4_reg;
        rv_p17_t1_reg            <=  rv_p17_t1_reg;
        rv_p17_t2_reg            <=  rv_p17_t2_reg;
        rv_p17_t3_reg            <=  rv_p17_t3_reg;
        rv_p17_t4_reg            <=  rv_p17_t4_reg;
        rv_p18_t1_reg            <=  rv_p18_t1_reg;
        rv_p18_t2_reg            <=  rv_p18_t2_reg;
        rv_p18_t3_reg            <=  rv_p18_t3_reg;
        rv_p18_t4_reg            <=  rv_p18_t4_reg;
        rv_p19_t1_reg            <=  rv_p19_t1_reg;
        rv_p19_t2_reg            <=  rv_p19_t2_reg;
        rv_p19_t3_reg            <=  rv_p19_t3_reg;
        rv_p19_t4_reg            <=  rv_p19_t4_reg;
        rv_p20_t1_reg            <=  rv_p20_t1_reg;
        rv_p20_t2_reg            <=  rv_p20_t2_reg;
        rv_p20_t3_reg            <=  rv_p20_t3_reg;
        rv_p20_t4_reg            <=  rv_p20_t4_reg;
        rv_p21_t1_reg            <=  rv_p21_t1_reg;
        rv_p21_t2_reg            <=  rv_p21_t2_reg;
        rv_p21_t3_reg            <=  rv_p21_t3_reg;
        rv_p21_t4_reg            <=  rv_p21_t4_reg;
        rv_p22_t1_reg            <=  rv_p22_t1_reg;
        rv_p22_t2_reg            <=  rv_p22_t2_reg;
        rv_p22_t3_reg            <=  rv_p22_t3_reg;
        rv_p22_t4_reg            <=  rv_p22_t4_reg;
        rv_p23_t1_reg            <=  rv_p23_t1_reg;
        rv_p23_t2_reg            <=  rv_p23_t2_reg;
        rv_p23_t3_reg            <=  rv_p23_t3_reg;
        rv_p23_t4_reg            <=  rv_p23_t4_reg;
        rv_p24_t1_reg            <=  rv_p24_t1_reg;
        rv_p24_t2_reg            <=  rv_p24_t2_reg;
        rv_p24_t3_reg            <=  rv_p24_t3_reg;
        rv_p24_t4_reg            <=  rv_p24_t4_reg;
        rv_p25_t1_reg            <=  rv_p25_t1_reg;
        rv_p25_t2_reg            <=  rv_p25_t2_reg;
        rv_p25_t3_reg            <=  rv_p25_t3_reg;
        rv_p25_t4_reg            <=  rv_p25_t4_reg;
        rv_p26_t1_reg            <=  rv_p26_t1_reg;
        rv_p26_t2_reg            <=  rv_p26_t2_reg;
        rv_p26_t3_reg            <=  rv_p26_t3_reg;
        rv_p26_t4_reg            <=  rv_p26_t4_reg;
        rv_p27_t1_reg            <=  rv_p27_t1_reg;
        rv_p27_t2_reg            <=  rv_p27_t2_reg;
        rv_p27_t3_reg            <=  rv_p27_t3_reg;
        rv_p27_t4_reg            <=  rv_p27_t4_reg;
        rv_p28_t1_reg            <=  rv_p28_t1_reg;
        rv_p28_t2_reg            <=  rv_p28_t2_reg;
        rv_p28_t3_reg            <=  rv_p28_t3_reg;
        rv_p28_t4_reg            <=  rv_p28_t4_reg;
        rv_p29_t1_reg            <=  rv_p29_t1_reg;
        rv_p29_t2_reg            <=  rv_p29_t2_reg;
        rv_p29_t3_reg            <=  rv_p29_t3_reg;
        rv_p29_t4_reg            <=  rv_p29_t4_reg;
        rv_p30_t1_reg            <=  rv_p30_t1_reg;
        rv_p30_t2_reg            <=  rv_p30_t2_reg;
        rv_p30_t3_reg            <=  rv_p30_t3_reg;
        rv_p30_t4_reg            <=  rv_p30_t4_reg;
        rv_p31_t1_reg            <=  rv_p31_t1_reg;
        rv_p31_t2_reg            <=  rv_p31_t2_reg;
        rv_p31_t3_reg            <=  rv_p31_t3_reg;
        rv_p31_t4_reg            <=  rv_p31_t4_reg;
    end

always @(posedge i_clk or negedge i_rst_n) 
    if(~i_rst_n)begin
        ov_p0_t1                 <=  80'd0;
        ov_p0_t2                 <=  80'd0;
        ov_p0_t3                 <=  80'd0;
        ov_p0_t4                 <=  80'd0;
        ov_p1_t1                 <=  80'd0;
        ov_p1_t2                 <=  80'd0;
        ov_p1_t3                 <=  80'd0;
        ov_p1_t4                 <=  80'd0;
        ov_p2_t1                 <=  80'd0;
        ov_p2_t2                 <=  80'd0;
        ov_p2_t3                 <=  80'd0;
        ov_p2_t4                 <=  80'd0;
        ov_p3_t1                 <=  80'd0;
        ov_p3_t2                 <=  80'd0;
        ov_p3_t3                 <=  80'd0;
        ov_p3_t4                 <=  80'd0;
        ov_p4_t1                 <=  80'd0;
        ov_p4_t2                 <=  80'd0;
        ov_p4_t3                 <=  80'd0;
        ov_p4_t4                 <=  80'd0;
        ov_p5_t1                 <=  80'd0;
        ov_p5_t2                 <=  80'd0;
        ov_p5_t3                 <=  80'd0;
        ov_p5_t4                 <=  80'd0;
        ov_p6_t1                 <=  80'd0;
        ov_p6_t2                 <=  80'd0;
        ov_p6_t3                 <=  80'd0;
        ov_p6_t4                 <=  80'd0;
        ov_p7_t1                 <=  80'd0;
        ov_p7_t2                 <=  80'd0;
        ov_p7_t3                 <=  80'd0;
        ov_p7_t4                 <=  80'd0;
        ov_p8_t1                 <=  80'd0;
        ov_p8_t2                 <=  80'd0;
        ov_p8_t3                 <=  80'd0;
        ov_p8_t4                 <=  80'd0;
        ov_p9_t1                 <=  80'd0;
        ov_p9_t2                 <=  80'd0;
        ov_p9_t3                 <=  80'd0;
        ov_p9_t4                 <=  80'd0;
        ov_p10_t1                <=  80'd0;
        ov_p10_t2                <=  80'd0;
        ov_p10_t3                <=  80'd0;
        ov_p10_t4                <=  80'd0;
        ov_p11_t1                <=  80'd0;
        ov_p11_t2                <=  80'd0;
        ov_p11_t3                <=  80'd0;
        ov_p11_t4                <=  80'd0;
        ov_p12_t1                <=  80'd0;
        ov_p12_t2                <=  80'd0;
        ov_p12_t3                <=  80'd0;
        ov_p12_t4                <=  80'd0;
        ov_p13_t1                <=  80'd0;
        ov_p13_t2                <=  80'd0;
        ov_p13_t3                <=  80'd0;
        ov_p13_t4                <=  80'd0;
        ov_p14_t1                <=  80'd0;
        ov_p14_t2                <=  80'd0;
        ov_p14_t3                <=  80'd0;
        ov_p14_t4                <=  80'd0;
        ov_p15_t1                <=  80'd0;
        ov_p15_t2                <=  80'd0;
        ov_p15_t3                <=  80'd0;
        ov_p15_t4                <=  80'd0;
        ov_p16_t1                <=  80'd0;
        ov_p16_t2                <=  80'd0;
        ov_p16_t3                <=  80'd0;
        ov_p16_t4                <=  80'd0;
        ov_p17_t1                <=  80'd0;
        ov_p17_t2                <=  80'd0;
        ov_p17_t3                <=  80'd0;
        ov_p17_t4                <=  80'd0;
        ov_p18_t1                <=  80'd0;
        ov_p18_t2                <=  80'd0;
        ov_p18_t3                <=  80'd0;
        ov_p18_t4                <=  80'd0;
        ov_p19_t1                <=  80'd0;
        ov_p19_t2                <=  80'd0;
        ov_p19_t3                <=  80'd0;
        ov_p19_t4                <=  80'd0;
        ov_p20_t1                <=  80'd0;
        ov_p20_t2                <=  80'd0;
        ov_p20_t3                <=  80'd0;
        ov_p20_t4                <=  80'd0;
        ov_p21_t1                <=  80'd0;
        ov_p21_t2                <=  80'd0;
        ov_p21_t3                <=  80'd0;
        ov_p21_t4                <=  80'd0;
        ov_p22_t1                <=  80'd0;
        ov_p22_t2                <=  80'd0;
        ov_p22_t3                <=  80'd0;
        ov_p22_t4                <=  80'd0;
        ov_p23_t1                <=  80'd0;
        ov_p23_t2                <=  80'd0;
        ov_p23_t3                <=  80'd0;
        ov_p23_t4                <=  80'd0;
        ov_p24_t1                <=  80'd0;
        ov_p24_t2                <=  80'd0;
        ov_p24_t3                <=  80'd0;
        ov_p24_t4                <=  80'd0;
        ov_p25_t1                <=  80'd0;
        ov_p25_t2                <=  80'd0;
        ov_p25_t3                <=  80'd0;
        ov_p25_t4                <=  80'd0;
        ov_p26_t1                <=  80'd0;
        ov_p26_t2                <=  80'd0;
        ov_p26_t3                <=  80'd0;
        ov_p26_t4                <=  80'd0;
        ov_p27_t1                <=  80'd0;
        ov_p27_t2                <=  80'd0;
        ov_p27_t3                <=  80'd0;
        ov_p27_t4                <=  80'd0;
        ov_p28_t1                <=  80'd0;
        ov_p28_t2                <=  80'd0;
        ov_p28_t3                <=  80'd0;
        ov_p28_t4                <=  80'd0;
        ov_p29_t1                <=  80'd0;
        ov_p29_t2                <=  80'd0;
        ov_p29_t3                <=  80'd0;
        ov_p29_t4                <=  80'd0;
        ov_p30_t1                <=  80'd0;
        ov_p30_t2                <=  80'd0;
        ov_p30_t3                <=  80'd0;
        ov_p30_t4                <=  80'd0;
        ov_p31_t1                <=  80'd0;
        ov_p31_t2                <=  80'd0;
        ov_p31_t3                <=  80'd0;
        ov_p31_t4                <=  80'd0;

    end
    else if((r_data_reg_flag == 1'b1) && (|rv_port_reg) && (i_rd == 1'b0))begin
        ov_p0_t1                 <=  rv_p0_t1_reg;
        ov_p0_t2                 <=  rv_p0_t2_reg;
        ov_p0_t3                 <=  rv_p0_t3_reg;
        ov_p0_t4                 <=  rv_p0_t4_reg;
        ov_p1_t1                 <=  rv_p1_t1_reg;
        ov_p1_t2                 <=  rv_p1_t2_reg;
        ov_p1_t3                 <=  rv_p1_t3_reg;
        ov_p1_t4                 <=  rv_p1_t4_reg;
        ov_p2_t1                 <=  rv_p2_t1_reg;
        ov_p2_t2                 <=  rv_p2_t2_reg;
        ov_p2_t3                 <=  rv_p2_t3_reg;
        ov_p2_t4                 <=  rv_p2_t4_reg;
        ov_p3_t1                 <=  rv_p3_t1_reg;
        ov_p3_t2                 <=  rv_p3_t2_reg;
        ov_p3_t3                 <=  rv_p3_t3_reg;
        ov_p3_t4                 <=  rv_p3_t4_reg;
        ov_p4_t1                 <=  rv_p4_t1_reg;
        ov_p4_t2                 <=  rv_p4_t2_reg;
        ov_p4_t3                 <=  rv_p4_t3_reg;
        ov_p4_t4                 <=  rv_p4_t4_reg;
        ov_p5_t1                 <=  rv_p5_t1_reg;
        ov_p5_t2                 <=  rv_p5_t2_reg;
        ov_p5_t3                 <=  rv_p5_t3_reg;
        ov_p5_t4                 <=  rv_p5_t4_reg;
        ov_p6_t1                 <=  rv_p6_t1_reg;
        ov_p6_t2                 <=  rv_p6_t2_reg;
        ov_p6_t3                 <=  rv_p6_t3_reg;
        ov_p6_t4                 <=  rv_p6_t4_reg;
        ov_p7_t1                 <=  rv_p7_t1_reg;
        ov_p7_t2                 <=  rv_p7_t2_reg;
        ov_p7_t3                 <=  rv_p7_t3_reg;
        ov_p7_t4                 <=  rv_p7_t4_reg;
        ov_p8_t1                 <=  rv_p8_t1_reg;
        ov_p8_t2                 <=  rv_p8_t2_reg;
        ov_p8_t3                 <=  rv_p8_t3_reg;
        ov_p8_t4                 <=  rv_p8_t4_reg;
        ov_p9_t1                 <=  rv_p9_t1_reg;
        ov_p9_t2                 <=  rv_p9_t2_reg;
        ov_p9_t3                 <=  rv_p9_t3_reg;
        ov_p9_t4                 <=  rv_p9_t4_reg;
        ov_p10_t1                <=  rv_p10_t1_reg;
        ov_p10_t2                <=  rv_p10_t2_reg;
        ov_p10_t3                <=  rv_p10_t3_reg;
        ov_p10_t4                <=  rv_p10_t4_reg;
        ov_p11_t1                <=  rv_p11_t1_reg;
        ov_p11_t2                <=  rv_p11_t2_reg;
        ov_p11_t3                <=  rv_p11_t3_reg;
        ov_p11_t4                <=  rv_p11_t4_reg;
        ov_p12_t1                <=  rv_p12_t1_reg;
        ov_p12_t2                <=  rv_p12_t2_reg;
        ov_p12_t3                <=  rv_p12_t3_reg;
        ov_p12_t4                <=  rv_p12_t4_reg;
        ov_p13_t1                <=  rv_p13_t1_reg;
        ov_p13_t2                <=  rv_p13_t2_reg;
        ov_p13_t3                <=  rv_p13_t3_reg;
        ov_p13_t4                <=  rv_p13_t4_reg;
        ov_p14_t1                <=  rv_p14_t1_reg;
        ov_p14_t2                <=  rv_p14_t2_reg;
        ov_p14_t3                <=  rv_p14_t3_reg;
        ov_p14_t4                <=  rv_p14_t4_reg;
        ov_p15_t1                <=  rv_p15_t1_reg;
        ov_p15_t2                <=  rv_p15_t2_reg;
        ov_p15_t3                <=  rv_p15_t3_reg;
        ov_p15_t4                <=  rv_p15_t4_reg;
        ov_p16_t1                <=  rv_p16_t1_reg;
        ov_p16_t2                <=  rv_p16_t2_reg;
        ov_p16_t3                <=  rv_p16_t3_reg;
        ov_p16_t4                <=  rv_p16_t4_reg;
        ov_p17_t1                <=  rv_p17_t1_reg;
        ov_p17_t2                <=  rv_p17_t2_reg;
        ov_p17_t3                <=  rv_p17_t3_reg;
        ov_p17_t4                <=  rv_p17_t4_reg;
        ov_p18_t1                <=  rv_p18_t1_reg;
        ov_p18_t2                <=  rv_p18_t2_reg;
        ov_p18_t3                <=  rv_p18_t3_reg;
        ov_p18_t4                <=  rv_p18_t4_reg;
        ov_p19_t1                <=  rv_p19_t1_reg;
        ov_p19_t2                <=  rv_p19_t2_reg;
        ov_p19_t3                <=  rv_p19_t3_reg;
        ov_p19_t4                <=  rv_p19_t4_reg;
        ov_p20_t1                <=  rv_p20_t1_reg;
        ov_p20_t2                <=  rv_p20_t2_reg;
        ov_p20_t3                <=  rv_p20_t3_reg;
        ov_p20_t4                <=  rv_p20_t4_reg;
        ov_p21_t1                <=  rv_p21_t1_reg;
        ov_p21_t2                <=  rv_p21_t2_reg;
        ov_p21_t3                <=  rv_p21_t3_reg;
        ov_p21_t4                <=  rv_p21_t4_reg;
        ov_p22_t1                <=  rv_p22_t1_reg;
        ov_p22_t2                <=  rv_p22_t2_reg;
        ov_p22_t3                <=  rv_p22_t3_reg;
        ov_p22_t4                <=  rv_p22_t4_reg;
        ov_p23_t1                <=  rv_p23_t1_reg;
        ov_p23_t2                <=  rv_p23_t2_reg;
        ov_p23_t3                <=  rv_p23_t3_reg;
        ov_p23_t4                <=  rv_p23_t4_reg;
        ov_p24_t1                <=  rv_p24_t1_reg;
        ov_p24_t2                <=  rv_p24_t2_reg;
        ov_p24_t3                <=  rv_p24_t3_reg;
        ov_p24_t4                <=  rv_p24_t4_reg;
        ov_p25_t1                <=  rv_p25_t1_reg;
        ov_p25_t2                <=  rv_p25_t2_reg;
        ov_p25_t3                <=  rv_p25_t3_reg;
        ov_p25_t4                <=  rv_p25_t4_reg;
        ov_p26_t1                <=  rv_p26_t1_reg;
        ov_p26_t2                <=  rv_p26_t2_reg;
        ov_p26_t3                <=  rv_p26_t3_reg;
        ov_p26_t4                <=  rv_p26_t4_reg;
        ov_p27_t1                <=  rv_p27_t1_reg;
        ov_p27_t2                <=  rv_p27_t2_reg;
        ov_p27_t3                <=  rv_p27_t3_reg;
        ov_p27_t4                <=  rv_p27_t4_reg;
        ov_p28_t1                <=  rv_p28_t1_reg;
        ov_p28_t2                <=  rv_p28_t2_reg;
        ov_p28_t3                <=  rv_p28_t3_reg;
        ov_p28_t4                <=  rv_p28_t4_reg;
        ov_p29_t1                <=  rv_p29_t1_reg;
        ov_p29_t2                <=  rv_p29_t2_reg;
        ov_p29_t3                <=  rv_p29_t3_reg;
        ov_p29_t4                <=  rv_p29_t4_reg;
        ov_p30_t1                <=  rv_p30_t1_reg;
        ov_p30_t2                <=  rv_p30_t2_reg;
        ov_p30_t3                <=  rv_p30_t3_reg;
        ov_p30_t4                <=  rv_p30_t4_reg;
        ov_p31_t1                <=  rv_p31_t1_reg;
        ov_p31_t2                <=  rv_p31_t2_reg;
        ov_p31_t3                <=  rv_p31_t3_reg;
        ov_p31_t4                <=  rv_p31_t4_reg;
    end
    else begin
        ov_p0_t1                 <=  ov_p0_t1;
        ov_p0_t2                 <=  ov_p0_t2;
        ov_p0_t3                 <=  ov_p0_t3;
        ov_p0_t4                 <=  ov_p0_t4;
        ov_p1_t1                 <=  ov_p1_t1;
        ov_p1_t2                 <=  ov_p1_t2;
        ov_p1_t3                 <=  ov_p1_t3;
        ov_p1_t4                 <=  ov_p1_t4;
        ov_p2_t1                 <=  ov_p2_t1;
        ov_p2_t2                 <=  ov_p2_t2;
        ov_p2_t3                 <=  ov_p2_t3;
        ov_p2_t4                 <=  ov_p2_t4;
        ov_p3_t1                 <=  ov_p3_t1;
        ov_p3_t2                 <=  ov_p3_t2;
        ov_p3_t3                 <=  ov_p3_t3;
        ov_p3_t4                 <=  ov_p3_t4;
        ov_p4_t1                 <=  ov_p4_t1;
        ov_p4_t2                 <=  ov_p4_t2;
        ov_p4_t3                 <=  ov_p4_t3;
        ov_p4_t4                 <=  ov_p4_t4;
        ov_p5_t1                 <=  ov_p5_t1;
        ov_p5_t2                 <=  ov_p5_t2;
        ov_p5_t3                 <=  ov_p5_t3;
        ov_p5_t4                 <=  ov_p5_t4;
        ov_p6_t1                 <=  ov_p6_t1;
        ov_p6_t2                 <=  ov_p6_t2;
        ov_p6_t3                 <=  ov_p6_t3;
        ov_p6_t4                 <=  ov_p6_t4;
        ov_p7_t1                 <=  ov_p7_t1;
        ov_p7_t2                 <=  ov_p7_t2;
        ov_p7_t3                 <=  ov_p7_t3;
        ov_p7_t4                 <=  ov_p7_t4;
        ov_p8_t1                 <=  ov_p8_t1;
        ov_p8_t2                 <=  ov_p8_t2;
        ov_p8_t3                 <=  ov_p8_t3;
        ov_p8_t4                 <=  ov_p8_t4;
        ov_p9_t1                 <=  ov_p9_t1;
        ov_p9_t2                 <=  ov_p9_t2;
        ov_p9_t3                 <=  ov_p9_t3;
        ov_p9_t4                 <=  ov_p9_t4;
        ov_p10_t1                <=  ov_p10_t1;
        ov_p10_t2                <=  ov_p10_t2;
        ov_p10_t3                <=  ov_p10_t3;
        ov_p10_t4                <=  ov_p10_t4;
        ov_p11_t1                <=  ov_p11_t1;
        ov_p11_t2                <=  ov_p11_t2;
        ov_p11_t3                <=  ov_p11_t3;
        ov_p11_t4                <=  ov_p11_t4;
        ov_p12_t1                <=  ov_p12_t1;
        ov_p12_t2                <=  ov_p12_t2;
        ov_p12_t3                <=  ov_p12_t3;
        ov_p12_t4                <=  ov_p12_t4;
        ov_p13_t1                <=  ov_p13_t1;
        ov_p13_t2                <=  ov_p13_t2;
        ov_p13_t3                <=  ov_p13_t3;
        ov_p13_t4                <=  ov_p13_t4;
        ov_p14_t1                <=  ov_p14_t1;
        ov_p14_t2                <=  ov_p14_t2;
        ov_p14_t3                <=  ov_p14_t3;
        ov_p14_t4                <=  ov_p14_t4;
        ov_p15_t1                <=  ov_p15_t1;
        ov_p15_t2                <=  ov_p15_t2;
        ov_p15_t3                <=  ov_p15_t3;
        ov_p15_t4                <=  ov_p15_t4;
        ov_p16_t1                <=  ov_p16_t1;
        ov_p16_t2                <=  ov_p16_t2;
        ov_p16_t3                <=  ov_p16_t3;
        ov_p16_t4                <=  ov_p16_t4;
        ov_p17_t1                <=  ov_p17_t1;
        ov_p17_t2                <=  ov_p17_t2;
        ov_p17_t3                <=  ov_p17_t3;
        ov_p17_t4                <=  ov_p17_t4;
        ov_p18_t1                <=  ov_p18_t1;
        ov_p18_t2                <=  ov_p18_t2;
        ov_p18_t3                <=  ov_p18_t3;
        ov_p18_t4                <=  ov_p18_t4;
        ov_p19_t1                <=  ov_p19_t1;
        ov_p19_t2                <=  ov_p19_t2;
        ov_p19_t3                <=  ov_p19_t3;
        ov_p19_t4                <=  ov_p19_t4;
        ov_p20_t1                <=  ov_p20_t1;
        ov_p20_t2                <=  ov_p20_t2;
        ov_p20_t3                <=  ov_p20_t3;
        ov_p20_t4                <=  ov_p20_t4;
        ov_p21_t1                <=  ov_p21_t1;
        ov_p21_t2                <=  ov_p21_t2;
        ov_p21_t3                <=  ov_p21_t3;
        ov_p21_t4                <=  ov_p21_t4;
        ov_p22_t1                <=  ov_p22_t1;
        ov_p22_t2                <=  ov_p22_t2;
        ov_p22_t3                <=  ov_p22_t3;
        ov_p22_t4                <=  ov_p22_t4;
        ov_p23_t1                <=  ov_p23_t1;
        ov_p23_t2                <=  ov_p23_t2;
        ov_p23_t3                <=  ov_p23_t3;
        ov_p23_t4                <=  ov_p23_t4;
        ov_p24_t1                <=  ov_p24_t1;
        ov_p24_t2                <=  ov_p24_t2;
        ov_p24_t3                <=  ov_p24_t3;
        ov_p24_t4                <=  ov_p24_t4;
        ov_p25_t1                <=  ov_p25_t1;
        ov_p25_t2                <=  ov_p25_t2;
        ov_p25_t3                <=  ov_p25_t3;
        ov_p25_t4                <=  ov_p25_t4;
        ov_p26_t1                <=  ov_p26_t1;
        ov_p26_t2                <=  ov_p26_t2;
        ov_p26_t3                <=  ov_p26_t3;
        ov_p26_t4                <=  ov_p26_t4;
        ov_p27_t1                <=  ov_p27_t1;
        ov_p27_t2                <=  ov_p27_t2;
        ov_p27_t3                <=  ov_p27_t3;
        ov_p27_t4                <=  ov_p27_t4;
        ov_p28_t1                <=  ov_p28_t1;
        ov_p28_t2                <=  ov_p28_t2;
        ov_p28_t3                <=  ov_p28_t3;
        ov_p28_t4                <=  ov_p28_t4;
        ov_p29_t1                <=  ov_p29_t1;
        ov_p29_t2                <=  ov_p29_t2;
        ov_p29_t3                <=  ov_p29_t3;
        ov_p29_t4                <=  ov_p29_t4;
        ov_p30_t1                <=  ov_p30_t1;
        ov_p30_t2                <=  ov_p30_t2;
        ov_p30_t3                <=  ov_p30_t3;
        ov_p30_t4                <=  ov_p30_t4;
        ov_p31_t1                <=  ov_p31_t1;
        ov_p31_t2                <=  ov_p31_t2;
        ov_p31_t3                <=  ov_p31_t3;
        ov_p31_t4                <=  ov_p31_t4; 
    end

// sync state cache
always @(posedge i_clk or negedge i_rst_n) 
    if(~i_rst_n)
        r_sync_state_wr_reg1                <=  1'b0;
    else
        r_sync_state_wr_reg1                <=  i_sync_state_wr;

assign  w_sync_state_rise                   =   ((i_sync_state_wr) && (~r_sync_state_wr_reg1))?1'b1:1'b0;
assign  w_sync_state_fall                   =   ((~i_sync_state_wr) && (r_sync_state_wr_reg1))?1'b1:1'b0;

always @(posedge i_clk or negedge i_rst_n)
    if(~i_rst_n)begin
        o_sync_ok                       <=  1'b0;
        ov_offset_abnormal_cnt          <=  16'b0;
        ov_offset                       <=  13'b0;
        ov_gm_timestamps                <=  80'b0;
        ov_correctfield_time            <=  64'b0;
        ov_mac_time                     <=  80'b0;  
        ov_tsc_time                     <=  80'b0;
        ov_sync_link_delay              <=  11'b0;
        ov_corrent_sync_clk             <=  80'b0;
        ov_clk_set_time                 <=  80'b0;
        ov_cyclestart_sequenceid        <=  32'b0;
        ov_tick_length                  <=  64'b0;
        ov_csrateoffset_previousnode    <=  32'b0;
        r_sync_ok_reg                   <=  1'b0;
        rv_offset_abnormal_cnt_reg      <=  16'b0;
        rv_offset_reg                   <=  13'b0;
        rv_gm_timestamps_reg            <=  80'b0;
        rv_correctfield_time_reg        <=  64'b0;
        rv_mac_time_reg                 <=  80'b0;  
        rv_tsc_time_reg                 <=  80'b0;
        rv_sync_link_delay_reg          <=  11'b0;
        rv_corrent_sync_clk_reg         <=  80'b0;
        rv_clk_set_time_reg             <=  80'b0;
        rv_cyclestart_sequenceid_reg    <=  32'b0;
        rv_tick_length_reg              <=  64'b0;
        rv_csrateoffset_previousnode_reg<=  32'b0;
    end
    else if((i_sync_state_wr == 1'b0) && (r_sync_state_wr_reg1 == 1'b0))begin
        r_sync_ok_reg                       <=  1'b0;
        rv_offset_abnormal_cnt_reg          <=  16'b0;
        rv_offset_reg                       <=  13'b0;
        rv_gm_timestamps_reg                <=  80'b0;
        rv_correctfield_time_reg            <=  64'b0;
        rv_mac_time_reg                     <=  80'b0;
        rv_tsc_time_reg                     <=  80'b0;
        rv_sync_link_delay_reg              <=  11'b0;
        rv_corrent_sync_clk_reg             <=  80'b0;
        rv_clk_set_time_reg                 <=  80'b0;
        rv_cyclestart_sequenceid_reg        <=  32'b0;
        rv_tick_length_reg                  <=  64'b0;
        rv_csrateoffset_previousnode_reg    <=  32'b0;
    end
    else if(i_sync_state_wr == 1'b1)begin
        r_sync_ok_reg                       <=  i_sync_ok;
        rv_offset_abnormal_cnt_reg          <=  iv_offset_abnormal_cnt;
        rv_offset_reg                       <=  iv_offset;
        rv_gm_timestamps_reg                <=  iv_gm_timestamps;
        rv_correctfield_time_reg            <=  iv_correctfield_time;
        rv_mac_time_reg                     <=  iv_mac_time;
        rv_tsc_time_reg                     <=  iv_tsc_time;
        rv_sync_link_delay_reg              <=  iv_sync_link_delay[27:16];
        rv_corrent_sync_clk_reg             <=  iv_corrent_sync_clk;
        rv_clk_set_time_reg                 <=  iv_clk_set_time[95:16];
        rv_cyclestart_sequenceid_reg        <=  iv_cyclestart_sequenceid;
        rv_tick_length_reg                  <=  iv_tick_length;
        rv_csrateoffset_previousnode_reg    <=  iv_csrateoffset_previousnode;
    end
    else if((w_sync_state_fall == 1'b1) && (i_rd == 1'b0))begin
        o_sync_ok                           <=  r_sync_ok_reg;
        ov_offset_abnormal_cnt              <=  rv_offset_abnormal_cnt_reg;
        ov_offset                           <=  rv_offset_reg;
        ov_gm_timestamps                    <=  rv_gm_timestamps_reg;
        ov_correctfield_time                <=  rv_correctfield_time_reg;
        ov_mac_time                         <=  rv_mac_time_reg;  
        ov_tsc_time                         <=  rv_tsc_time_reg;
        ov_sync_link_delay                  <=  rv_sync_link_delay_reg;
        ov_corrent_sync_clk                 <=  rv_corrent_sync_clk_reg;
        ov_clk_set_time                     <=  rv_clk_set_time_reg;
        ov_cyclestart_sequenceid            <=  rv_cyclestart_sequenceid_reg;
        ov_tick_length                      <=  rv_tick_length_reg;
        ov_csrateoffset_previousnode        <=  rv_csrateoffset_previousnode_reg;
    end
    else begin
        r_sync_ok_reg                       <=  r_sync_ok_reg;
        rv_offset_abnormal_cnt_reg          <=  rv_offset_abnormal_cnt_reg;
        rv_offset_reg                       <=  rv_offset_reg;
        rv_gm_timestamps_reg                <=  rv_gm_timestamps_reg;
        rv_correctfield_time_reg            <=  rv_correctfield_time_reg;
        rv_mac_time_reg                     <=  rv_mac_time_reg;  
        rv_tsc_time_reg                     <=  rv_tsc_time_reg;
        rv_sync_link_delay_reg              <=  rv_sync_link_delay_reg;
        rv_corrent_sync_clk_reg             <=  rv_corrent_sync_clk_reg;
        rv_clk_set_time_reg                 <=  rv_clk_set_time_reg;
        rv_cyclestart_sequenceid_reg        <=  rv_cyclestart_sequenceid_reg;
        rv_tick_length_reg                  <=  rv_tick_length_reg;
        rv_csrateoffset_previousnode_reg    <=  rv_csrateoffset_previousnode_reg;
        o_sync_ok                           <=  o_sync_ok;
        ov_offset_abnormal_cnt              <=  ov_offset_abnormal_cnt;
        ov_offset                           <=  ov_offset;
        ov_gm_timestamps                    <=  ov_gm_timestamps;
        ov_correctfield_time                <=  ov_correctfield_time;
        ov_mac_time                         <=  ov_mac_time;
        ov_tsc_time                         <=  ov_tsc_time;
        ov_sync_link_delay                  <=  ov_sync_link_delay;
        ov_corrent_sync_clk                 <=  ov_corrent_sync_clk;
        ov_clk_set_time                     <=  ov_clk_set_time;
        ov_cyclestart_sequenceid            <=  ov_cyclestart_sequenceid;
        ov_tick_length                      <=  ov_tick_length;
        ov_csrateoffset_previousnode        <=  ov_csrateoffset_previousnode;

    end
        



   


endmodule